﻿<%@ Page Title="" Language="C#" MasterPageFile="~/pages/master/WebList.Master" AutoEventWireup="true"
    CodeBehind="ChildList.aspx.cs" Inherits="BF.Web.ChildList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceJs" runat="server">
    <script src="../../../script/OpenQuery.js" type="text/javascript"></script>
    <script type="text/javascript">
        function OnServerQuery() {
            //排序按钮显示控制
            //InitialBtnSort();
            __doPostBack('ctl00$ContentPlaceHtml$btnQuery', '');
            return false;
        }
        function Add() {
            var parentID = $(":checkbox:checked").val();
            var isSystem = $("#div_scroll_x :checkbox:checked").attr("isSystem");
            //系统字典不能修改 停用 
            if (isSystem == "1") {
                Ext.MessageBox.show({ title: '提示', msg: '系统字典不能新增！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            winer.OpenWin('字典新增', GetUrl(this) + 'DictEdit.aspx?opt=Add&parentid=' + $("#ctl00_ContentPlaceHtml_hideGkey").val(), 550, 320, false, this);
            return false;
        }
        //暂时没用到
        function CheckSelecte() {

            if ($("#div_scroll_x :checkbox:checked").length == 0) {//只能选择一项的判断
                Ext.MessageBox.show({ title: '提示', msg: '请选择要新增的记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            if ($("#div_scroll_x :checkbox:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({ title: '提示', msg: '只能选择一条记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }

            return true;
        }
        //停用、启用
        var titleStop = "提示";
        var msgStop = "请选择要停用的记录！";
        var configStop = "是否确认要停用记录？";
        function Stop() {
            var isDelete = $("#div_scroll_x :checkbox:checked");
            var isSystem = $("#div_scroll_x :checkbox:checked").attr("isSystem");
            if (isDelete.length == 0) {
                Ext.MessageBox.show({ title: titleStop, msg: msgStop, buttons: { ok: '确  定' }, icon: 'ext-mb-question' });
                return false;
            } else if (isSystem == "1") {
                //            //系统字典不能修改 停用 
                Ext.MessageBox.show({ title: '提示', msg: '系统字典不能停用！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            else {
                Ext.MessageBox.show({
                    title: titleStop,
                    msg: configStop,
                    buttons: { yes: '确  定', no: '取 消' },
                    fn: function (result) {
                        if (result == 'yes') {
                            __doPostBack("ctl00$ContentPlaceHtml$lbtnStop", "");
                        }
                    },
                    icon: 'ext-mb-info'
                });
                return false;
            }
        }

        //弹出修改窗口
        function Update() {
            if ($("#div_scroll_x :checkbox:checked").length == 0) {
                Ext.MessageBox.show({ title: '提示', msg: '请选择要修改的记录!', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            if ($("#div_scroll_x :checkbox:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({ title: '提示', msg: '只能选择一条记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            var values = $("#div_scroll_x :checkbox:checked").val();
            var isSystem = $("#div_scroll_x :checkbox:checked").attr("isSystem");
            //系统字典不能修改 停用 
            if (isSystem == "1") {
                Ext.MessageBox.show({ title: '提示', msg: '系统字典不能修改！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            winer.OpenWin('字典修改', GetUrl(this) + 'DictEdit.aspx?gKey=' + values + "&opt=Update", 550, 320, false, this);
            return false;
        }

        //弹出查看窗口
        function View(sKey) {
            winer.OpenWin('字典修改', GetUrl(this) + 'DictEdit.aspx?gKey=' + sKey + "&opt=View", 550, 320, false, this);
            return false;
        }

        //关闭弹出window时，执行的事件
        function Refurbish() {
            //排序按钮显示控制
            //InitialBtnSort();
            __doPostBack('ctl00$ContentPlaceHtml$anpDict', '')
        }

        function checkStop(obj) {
            //停用启用状态
            var state = "";
            $("#div_scroll_x :checkbox:checked").each(function () {
                state += $(this).attr("accesskey") + "#";
            })

            if (state.indexOf("0#1#") != -1 || state.indexOf("1#0#") != -1) {
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "disabled");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", "javascript:void(0);");
                return false;
            }

            if (state.indexOf("0#") != -1) {
                $("#ctl00_ContentPlaceHtml_hideStop").val("1");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", " javascript: __doPostBack('ctl00$ContentPlaceHtml$lbtnStop', '')")
                $('#divStop').html('启用');
                titleStop = "提示";
                msgStop = "请选择要启用的记录";
                configStop = "是否确认要启用的记录？";
                return false;
            }
            if (state.indexOf("1#") != -1) {
                $("#ctl00_ContentPlaceHtml_hideStop").val("0");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "");
                $('#divStop').html('停用');
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", " javascript: __doPostBack('ctl00$ContentPlaceHtml$lbtnStop', '')")
                titleStop = "提示";
                msgStop = "请选择要停用的记录！";
                configStop = "是否确认要停用记录？";
                return false;
            }

        }

        function OnUp() {
            if ($("input[name*='cbxGKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要向上的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            if ($("input[name*='cbxGKey']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '只能选择一条记录!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            return true;
        }

        function OnDown() {
            if ($("input[name*='cbxGKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要向下的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            if ($("input[name*='cbxGKey']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '只能选择一条记录!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            return true;
        }

        //扩展排序功能
        function OnOrder(obj) {
            $(obj).hide();
            $("#viewiSortHead").hide();
            $("#tbList .viewiSortTD").each(function () {
                $(this).hide();
            });

            $("#inputiSortHead").show();
            $("#tbList .inputiSortTD").each(function () {
                $(this).show();
            });
            $("#ctl00_ContentPlaceHtml_lbtnSaveOrder").show();
            $("#ctl00_ContentPlaceHtml_HFShowValue").val("inline");
            return false;
        }
        //验证序号
        function OnSaveOrderValidate() {
            $("#ctl00_ContentPlaceHtml_HFiSortgKey").val("");
            $("#ctl00_ContentPlaceHtml_HFiSortValue").val("");
            var msg = "";
            var tempgKey = "";
            var tempSort = "";
            var result = true;
            $("#tbList .inputiSortTD").each(function () {
                if ($.trim($(this).find("input").val()) == "") {
                    msg = "排序序号存在空项！";
                    result = false;
                    return;
                }
                if (tempSort.indexOf("^" + $.trim($(this).find("input").val()) + "^") != -1) {
                    msg = "排序序号存在重复项！";
                    result = false;
                    return;
                }
                else {
                    tempgKey += $.trim($(this).find("input").attr("class")) + "^"
                    tempSort += $.trim($(this).find("input").val()) + "^";
                }
            });
            //提示信息
            if (msg != "") { ShowMessage(msg); }
            $("#ctl00_ContentPlaceHtml_HFiSortgKey").val(tempgKey);
            $("#ctl00_ContentPlaceHtml_HFiSortValue").val(tempSort); 
            return result;
        }

        function ShowMessage(msg) {
            Ext.MessageBox.show({
                title: '提示',
                msg: msg,
                buttons: { ok: '确  定' },
                icon: 'ext-mb-info'
            });
        }
        //只能输入实数
        function JxkhCehck(t) {
            var value = t.value;
            if ((/^(\+|-)?\d+$/.test(value)) && value >= 0) { }
            else { t.value = ""; }
        }
        //        function InitialBtnSort() {
        //            //排序按钮显示控制  InitialBtnSort()
        //            $("#ctl00_ContentPlaceHtml_lbtnOrder").show();
        //            $("#ctl00_ContentPlaceHtml_lbtnSaveOrder").hide();
        //            $("#ctl00_ContentPlaceHtml_HFShowValue").val("none");
        //        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHtml" runat="server">
    <table id="tabHead" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
        class="listtop1">
        <tr>
            <td id="QueryCondition" style="border-bottom: 1px solid #8db2e3;">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-bottom: 5px;
                    margin-top: 4px;" class="content04 ">
                    <tr>
                        <td align="right">
                            明细编码：
                        </td>
                        <td>
                            <asp:TextBox ID="tbxSearch" MaxLength="50" runat="server"></asp:TextBox>
                        </td>
                        <td align="right">
                            明细名称：
                        </td>
                        <td>
                            <asp:TextBox ID="txtName" MaxLength="50" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table id="" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                    style="margin-bottom: 2px; margin-top: 2px; height: 26px;">
                    <tr>
                        <td>
                            <div class="btn01">
                                <asp:LinkButton ID="btnQuery" runat="server" OnClientClick="return OnServerQuery()"
                                    OnClick="btnQuery_Click">
                            <span>
                                <img src="../../../../images/search.png" alt="" border="0" /><div class="center">
                                    查询</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="btnAdd" runat="server" OnClientClick="return Add();">
                            <span>
                                <img src="../../../../images/table_add.png" alt="" border="0" /><div class="center">
                                    新增</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="btnUpdate" OnClientClick="return Update();" runat="server">
                            <span>
                                <img src="../../../../images/table_edit.png" alt="" border="0" /><div class="center">
                                    修改</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="lbtnStop" runat="server" OnClientClick="return Stop();" OnClick="lbtnStop_Click">
                            <span>
                                <img src="../../../../images/table_delete.png" alt="" border="0" /><div class="center" id="divStop">
                                    停用</div>
                            </span>
                                </asp:LinkButton><%-- 1：启用 0：停用--%><asp:HiddenField ID="hideStop" runat="server"
                                    Value="0" />
                                <asp:LinkButton ID="lbtnUp" Style="display: none" runat="server" OnClientClick="return OnUp();"
                                    OnClick="lbtnUp_Click">
                            <span>
                                <img src="../../../images/arrow_up.png" alt="" border="0" /><div class="center">向上</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="lbtnDown" Style="display: none" runat="server" OnClientClick="return OnDown();"
                                    OnClick="lbtnDown_Click">
                            <span>
                                <img src="../../../images/arrow_down.png" alt="" border="0" /><div class="center">向下</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="lbtnOrder" runat="server" OnClientClick="return OnOrder(this);">
                            <span>
                                <img src="../../../images/table_lightning.png" alt="" border="0" /><div class="center">排序</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="lbtnSaveOrder" Style="display: none" runat="server" OnClick="lbtnSaveOrder_Click"
                                    OnClientClick="return OnSaveOrderValidate();">
                            <span>
                                <img src="../../../images/page_save.png" alt="" border="0" /><div class="center">保存排序</div>
                            </span>
                                </asp:LinkButton>
                                <asp:HiddenField ID="hideGkey" runat="server" />
                                <asp:HiddenField ID="HFiSortgKey" runat="server" />
                                <asp:HiddenField ID="HFiSortValue" runat="server" />
                                <asp:HiddenField ID="HFShowValue" runat="server" Value="none" />
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div id="div_scroll_x" class="div_scroll">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Repeater ID="rptDict" runat="server">
                    <HeaderTemplate>
                        <table id="tbList" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                            class="list">
                            <thead>
                                <tr>
                                    <td align="center" style="width: 32px;">
                                        选择
                                    </td>
                                    <td align="center" style="width: 120px;">
                                        目录编码
                                    </td>
                                    <td align="center" style="width: 120px;">
                                        明细编码
                                    </td>
                                    <td align="center" style="width: 120px;">
                                        明细名称
                                    </td>
                                    <td align="center">
                                        备注
                                    </td>
                                    <td align="center" style="width: 64px;">
                                        有效标识
                                    </td>
                                    <td align="center" style="width: 30px; display: <%=GetDispalyStr(1) %>" id="viewiSortHead">
                                        排序
                                    </td>
                                    <td align="center" style="width: 50px; display: <%=GetDispalyStr(2) %>" id="inputiSortHead">
                                        新序号
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td align="center">
                                <input type="checkbox" name="checkbox1" id="cbxGKey" accesskey='<%#Eval("iUse") %>'
                                    isort='<%#Eval("iSort") %>' issystem='<%#Eval("isSystem") %>' runat="server"
                                    onclick="checkStop(this)" value='<%#Eval("gKey")%>' />
                            </td>
                            <td <%#(int)Eval("iUse") == 0 ?"style=\"color:Red\"":"" %> align="center">
                                <div class="divnr-auto" title='<%#Eval("sTableCode") %>'>
                                    <%#Eval("sTableCode")%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sCode")%>'>
                                    <a href="#" onclick="View('<%#Eval("gKey") %>')">
                                        <%#Eval("sCode")%></a></div>
                            </td>
                            <td <%#(int)Eval("iUse") == 0 ?"style=\"color:Red\"":"" %> align="left">
                                <div class="divnr-auto" title='<%#Eval("sName")%>'>
                                    <%#Eval("sName")%></div>
                            </td>
                            <td <%#(int)Eval("iUse") == 0 ?"style=\"color:Red\"":"" %> align="left">
                                <div class="divnr-auto" title='<%#Eval("sMemo")%>'>
                                    <%#Eval("sMemo")%></div>
                            </td>
                            <td <%#(int)Eval("iUse") == 0 ?"style=\"color:Red\"":"" %> align="center">
                                <div class="divnr-auto" title='<%#Eval("iUse")%>'>
                                    <%#(int)Eval("iUse")==1?"已启用":"已停用"%></div>
                            </td>
                            <td align="center" style='<%#(int)Eval("iUse") == 0 ?"color:Red;": "" %> display: <%=GetDispalyStr(1) %>'
                                class="viewiSortTD">
                                <div class="divnr-auto" title='<%#Eval("iSort")%>'>
                                    <%#Eval("iSort")%></div>
                            </td>
                            <td align="center" style='<%#(int)Eval("iUse") == 0 ?"color:Red;": "" %>display: <%=GetDispalyStr(2) %>'
                                class="inputiSortTD">
                                <input type="text" value="<%# Eval("iSort") %>" style="width: 30px; border: solid 1px #999;
                                    text-align: center" maxlength="3" class="<%# Eval("gKey") %>" onkeyup="JxkhCehck(this)" />
                            </td>
                            <td>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </tbody> </table>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="anpDict" EventName="PageChanged" />
                <asp:AsyncPostBackTrigger ControlID="lbtnStop" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnUp" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnDown" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnSaveOrder" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div class="div_AspNetPager">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="fengye">
                    <tr>
                        <td>
                            <webdiyer:AspNetPager ID="anpDict" runat="server" meta:resourcekey="anpDict" PageSize="15"
                                OnPageChanged="anpDict_PageChanged">
                            </webdiyer:AspNetPager>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="lbtnStop" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnUp" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnDown" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnSaveOrder" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div id="divCondition" class="window" style="width: 480px; display: none" runat="server">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="content04">
            <%--            <tr>
                <td align="left" style="width: 70px;">
                    明细编码：
                </td>
                <td align="left" style="width: 160px;">
                    <asp:TextBox ID="tbxSearch" MaxLength="50"  runat="server"></asp:TextBox>
                </td>
                                                <td align="left" style="width: 70px;">
                    明细名称：
                </td>
                                <td align="left" style="width: 160px;">
                    <asp:TextBox ID="txtName" MaxLength="50"  runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                            <td colspan="2" align="left">
                    有效标识：<asp:CheckBox ID="cbxFlagState" style="padding-left:14px;" Checked="true" Text="*打√启用" runat="server" />
                </td>
            </tr>--%>
        </table>
    </div>
</asp:Content>
